<?php
	header("charset=utf-8");
	include("conn.php");
	$x = $_POST['Name'];

	$cx =$db->prepare("select * from file where name=?");
	$cx->execute(array($x));
	$y=array();
	$result= $cx->fetch(PDO::FETCH_ASSOC);
	$y=$result['address'];
	$path=$y;//路径

	if ($result['type']=="资料") {
		# code...
		if(file_exists($path)){
			$res = unlink($path);
			if ($res) {
				$stmt = $db->prepare("delete from file where name=?");
				$stmt->execute(array($x));
				
			}
		}
	}
	else if ($result['type']=="小道消息") {
		$stmt = $db->prepare("delete from file where name=?");
		$stmt->execute(array($x));	
	}

	$stmt = $db->prepare("select * from file");
	$stmt->execute();
	$p=array();
	while($result= $stmt->fetch(PDO::FETCH_ASSOC))
		$p[] = $result;
	echo json_encode($p);
?>